﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SaleManagement.Models;
using SaleManagement.Controllers;
using SaleManagement.Common;
namespace SaleManagement.modules
{
    public partial class usKhohang : BaseUC
    {
        private WarehouseController whc;
        public usKhohang()
            : base()
        {
            InitializeComponent();
            whc = new WarehouseController();
        }

        public override void onLoad()
        {
            this.DataGridView.DataSource = whc.select(2);
        }
        public override void InitGridData()
        {
            this.DataGridView.AutoGenerateColumns = false;
            this.DataGridView.ColumnHeadersVisible = true;
            DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle();
            columnHeaderStyle.BackColor = Color.Beige;
            columnHeaderStyle.Font = new Font("Verdana", 10, FontStyle.Bold);
            DataGridView.ColumnHeadersDefaultCellStyle = columnHeaderStyle;


            DataGridViewTextBoxColumn idColumn = new DataGridViewTextBoxColumn();
            idColumn.DataPropertyName = "id";
            idColumn.HeaderText = "Id";

            DataGridViewTextBoxColumn nameColumn = new DataGridViewTextBoxColumn();
            nameColumn.DataPropertyName = "name";
            nameColumn.HeaderText = "Name";

            DataGridViewTextBoxColumn created_atColumn = new DataGridViewTextBoxColumn();
            created_atColumn.DataPropertyName = "created_at";
            created_atColumn.HeaderText = "CreateAt";

            DataGridViewTextBoxColumn addressColumn = new DataGridViewTextBoxColumn();
            addressColumn.DataPropertyName = "address";
            addressColumn.HeaderText = "Address";

            DataGridViewTextBoxColumn commentsColumn = new DataGridViewTextBoxColumn();
            commentsColumn.DataPropertyName = "comments";
            commentsColumn.HeaderText = "Comments";

            DataGridView.Columns.Add(idColumn);
            DataGridView.Columns.Add(nameColumn);
            DataGridView.Columns.Add(created_atColumn);
            DataGridView.Columns.Add(addressColumn);
            DataGridView.Columns.Add(commentsColumn);
        }
        
        public override void OnAdd(object sender, EventArgs e)
        {
            frmAdd_Edit_KhoHang fm = new frmAdd_Edit_KhoHang();
            if (fm.ShowDialog() == DialogResult.OK)
            {
                
            }
        }
        public override void OnEdit(object sender, EventArgs e)
        {
            frmAdd_Edit_KhoHang fm = new frmAdd_Edit_KhoHang();
            if (fm.ShowDialog() == DialogResult.OK)
            {
                
            }
        }
        public override void OnDelete(object sender, EventArgs e)
        {
        }
        public override void OnGridDataCellClick(object sender, DataGridViewCellEventArgs e)
        {
            //IdWarehouse=this.DataGridView.SelectedCells[0].Value.ToString();
            //row = DataGridView.CurrentCell.RowIndex;
        }

    }
}
